import { createRouter, createWebHistory } from 'vue-router'

import Home from '@/views/home/index.vue'
import Kind from '@/views/kind/index.vue'
import Cart from '@/views/cart/index.vue'
import User from '@/views/user/index.vue'

const routes = [
  // redirect 路由重定向
  {
    path: '/',
    // 当访问 / 的时候将路径改到 /home
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'home',
    component: Home
  },
  {
    path: '/kind',
    name: 'kind',
    component: Kind
  },
  {
    path: '/cart',
    name: 'cart',
    component: Cart
  },
  {
    path: '/user',
    name: 'user',
    component: User
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router
